﻿using B.S.BaseData.Domain;
using B.S.BaseData.ErrorCode;
using B.S.BaseData.Read.API.Application.Command;
using B.S.BaseData.Read.API.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using S.Y.Passport.Write.API.Applications.Commands;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

namespace B.S.BaseData.Read.API.Controllers
{
    /// <summary>
    /// API控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodsInfoController : ControllerBase
    {
        /// <summary>
        /// 中介者
        /// </summary>
        private readonly IMediator mediator;

        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="mediator"></param>
        public GoodsInfoController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 查询数据
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<ApiPaging<GoodsDTO>>> GetGoodsInfo([FromQuery] GoodsInfoQueryCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 查询商品名称
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<GoodsType>>> GetGoodsType([FromQuery] GoodsTypeQueryCommand command)
        {
            return mediator.Send(command);
        }

        /// <summary>
        /// 养殖信息差查询
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiResult<List<BreedingInfo>>> GetBreeding([FromQuery] BreedingQueryCommand command)
        {
            return mediator.Send(command);
        }
        /// <summary>
        /// 详情
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<GoodsInfo>> XiangGoodsQuery([FromQuery]XiangGoodsQueryCommand command)
        {
            return mediator.Send(command);
        }
    }
}

